<?php
$this->useClass("Handler_Community");
class Action_Community_DeleteCommunity extends Handler_Community
{
	public function process ()
	{	
		$aa = $this->aa;
		$aa->getInfo();
		if ($aa->acl_data['role']['name']!="moderator") {
			$view = $this->rh->views->findByName('accessdnd');
			$view->data = $aa->template_data;
			$this->rh->response->setContent( $view );
			
			return;
		}
		
		$this->ctx->db->begin();
				
		$this->deleteCommunity($aa->acl_data['comity_oid']);		
		
		if (!$this->ctx->db->isErrorInTransaction()) {
										
			$this->ctx->db->end();
			$view = $this->rh->views->findByName('deletecommunity_success');
			
		} else {
			$this->ctx->db->rollback();
			$this->rh->response->setContent("Ошибка при запросе в БД.");
			return;
		}
		
		$view->data = $aa->template_data;

		$this->rh->response->setContent($view);
	} // end of function process

}

